package org.xx.armory.spring5.autoconfigure;

import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.xx.armory.spring5.wxwork.WxWorkClient;

@Configuration
@ConditionalOnProperty(prefix = "armory.wx-work",
                       name = {"corp-id", "agent-id", "agent-secret"})
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
public class ArmoryWxWorkAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public WxWorkClient wxWorkClient() {
        return new WxWorkClient();
    }
}
